package com.bjc.www;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: 阿宾
 * Date: 2024-05-11
 * Time: 15:20
 */
class Student {
    private String name;
    private int age;
    //就地初始化
    public static String classRoom = "111";

    //封装方法：
    public int getAge() {
        return age;
    }
    public void setAge(int age) {
        this.age = age;
    }
    public String getName(){
        return this.name;
    }
    public void setName(String name){
        this.name = name;
    }
    //构造方法
    public Student(){

    }
    public Student(String name,int age){
        this.name = name;
        this.age = age;
    }
    //行为:学习 吃饭
    public void study(){
        System.out.println("学生学习...");
    }
    public void eat(String name){
        this.name = name;
        System.out.println(name+"吃饭...");
        func();
    }
    public static void func(){
        System.out.println("这是一个静态方法");
        //study(); //error 不能再静态方法里调用非静态方法
        //静态方法里调用非静态方法:需要先实例化，然后通过对象名.成员方法
        Student stu = new Student();
        stu.study();
    }
}
public class Test01 {
    public static void main(String[] args) {
        Student stu1 = new Student("小明",15);
        stu1.study();



        System.out.println(stu1.getName());
        Student stu2 = new Student("小张",20);

        Student.classRoom = "111";
    }
}
